﻿using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

namespace Puppy.Modularity.PlugIns
{
    public static class PlugInSourceListExtensions
    {
        public static Type[] GetModules([NotNull] this IPlugInSource plugInSource)
        {
            Check.NotNull(plugInSource, nameof(plugInSource));

            return plugInSource
                .GetModules()
                .Distinct()
                .ToArray();
        }

        public static void AddFolder(
            [NotNull] this PlugInSourceList list,
            [NotNull] string folder,
            SearchOption searchOption = SearchOption.TopDirectoryOnly,
            Func<string, bool> filter = null)
        {
            Check.NotNull(list, nameof(list));

            list.Add(new FolderPlugInSource(folder, searchOption, filter));
        }

        public static void UseApplicationFolder()
        {

        }
    }
}